{extend name='main'}

{block name='content'}
{php}
{//var_dump($userinfo);}
{/php}
<style>

    .store-total-container {
        font-size: 14px;
        margin-bottom: 20px;
        letter-spacing: 1px;
    }

    .store-total-container .store-total-icon {
        top: 45%;
        right: 8%;
        font-size: 65px;
        position: absolute;
        color: rgba(255, 255, 255, 0.4);
    }

    .store-total-container .store-total-item {
        color: #fff;
        line-height: 4em;
        padding: 15px 25px;
        position: relative;
    }

    .store-total-container .store-total-item > div:nth-child(2) {
        font-size: 46px;
        line-height: 46px;
    }
    .grid-demo a{
       color: #333;
    }
    .mainbox-width{
        width: 80%;
    }
    .right-box{
        top: 104px;
        position: fixed;
        width: 14%;
        left: 83%;
        max-height: 413px;
        min-height: 413px;
    }
    .uhead-imgbox{
        margin: 0 auto;
        border-radius: 50%;
    }
    @media screen and (max-width: 964px) {

        .right-box{display: none!important;}
        .mainbox-width{width: 96%;}
}
/*    @media screen and (max-width: 420px) {
            .right-box{display: none;}
}*/
        
</style>

<div class="think-box-shadow store-total-container">
    <div class="">
        
        <p class="font-s12">&nbsp;&nbsp;<i class="layui-icon layui-icon-app" style="font-size: 20px; color: #f39526; padding-right:5px;vertical-align: middle;"></i>{$userinfo['db2']['company_name']}-{$userinfo['db1']['username']}</p>

    </div>

</div>


<div class="think-box-shadow store-total-container mainbox-width">
    <div class="margin-bottom-15">数据统计</div>
    <div class="layui-row layui-col-space15">
        {if $userinfo['db1']['authorize'] == 0 || $userinfo['db1']['authorize']== 1 || $userinfo['db1']['authorize']== 8}
        <div class="layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-125deg,#57bdbf,#2f9de2)">
                <div>企业入驻总量</div>
                <div id="count-company">{$historydata.count_company}</div>
                <div>当前入驻企业</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-template-1"></i>
        </div>
        {/if}
        {if $userinfo['db1']['authorize'] != 8}
        <div class="layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-125deg,#ff7d7d,#fb2c95)">
                <div>用户总量</div>
                <div id="count-user">{$historydata.count_user}</div>
                <div>当前用户总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-user"></i>
        </div>
        {/if}
   
<!--         <div class="layui-col-sm6 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-113deg,#c543d8,#925cc3)">
                <div>访问数量</div>
                <div id="count-visit">{$historydata.count_visit}</div>
                <div>来访总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-read"></i>
        </div>
        <div class="layui-col-sm6 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-141deg,#ecca1b,#f39526)">
                 <div>预约总量</div>
                <div id="count-appointment">{$historydata.count_appointment}</div>
                 <div>发出预约函总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-survey"></i>
        </div> -->
        
                <div class="layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-113deg,#c543d8,#925cc3)">
                <div>今日到访人数</div>
                <div id="count-visit">{$historydata.nowday_appuser}</div>
                <div>来访总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-read"></i>
        </div>
        <div class="layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-141deg,#ecca1b,#f39526)">
                 <div>今日预约人数</div>
                <div id="count-appointment">{$historydata.nowday_readyuser}</div>
                 <div>预约总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-survey"></i>
        </div>
    </div>
</div>

<div class="think-box-shadow store-total-container mainbox-width">
    <div class="margin-bottom-15">实时概况</div>
    <div class="layui-row layui-col-space15">

       {if $userinfo['db1']['authorize']==0 || $userinfo['db1']['authorize']==1}
        <div class="layui-col-md6 margin-bottom-15">
            <div class="layui-row">
                <div class="layui-col-xs3 text-center">
                    <i class="layui-icon color-orange" style="font-size:60px;line-height:72px">&#xe65e;</i>
                </div>
                <div class="layui-col-xs4">
                    <div class="font-s14">企业入驻(收益)</div>
                    <div class="font-s16">{$historydata.count_income?:0}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.count_yesterday_income?:0}</div>
                </div>
                <div class="layui-col-xs5">
                    <div class="font-s14">产生会员</div>
                    <div class="font-s16">{$historydata.count_member}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.count_yesterday_member}</div>
                </div>
            </div>
        </div>
        {/if}
        <div class="layui-col-md6 margin-bottom-15">
            <div class="layui-row">
                <div class="layui-col-xs3 text-center">
                    <i class="layui-icon color-blue" style="font-size:60px;line-height:72px">&#xe663;</i>
                </div>
                {if $userinfo['db1']['authorize'] != 8}
                <div class="layui-col-xs4">
                    <div class="font-s14">新增用户数</div>
                    <div class="font-s16">{$historydata.nowday_user}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.yesterday_user}</div>
                </div>
                {/if}
                <div class="layui-col-xs5">
                    <div class="font-s14">产生访问用户数</div>
                    <div class="font-s16">{$historydata.count_visit_user}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.count_yesterday_visit_user?:0}</div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="think-box-shadow store-total-container mainbox-width right-box">
    <!--<div class="margin-bottom-15"><i class="layui-icon layui-icon-username" style="font-size: 30px;"></i>&nbsp;<small id="timeer"></small></div>-->
    <div class="layui-row layui-col-space15">

        <div class="layui-col-md12 margin-bottom-15">
            <div class="layui-row">
                <div class="text-center">
                    <div class="layui-carousel uhead-imgbox" id="uhead-img">
                      <div carousel-item  class="uhead-imgbox">
                        {if $userinfo['db2']}
                        <!--<div style="background-image: url({$userinfo['db2']['headimgurl']});background-size: 100% 100%;background-repeat: no-repeat;"></div>-->
                         <div style="background-image: url(http://devs.zsicp.com/public/upload/person/{$userinfo['db2']['personimg']});background-size: 100% 100%;background-repeat: no-repeat;"></div>
                         {else}
                         <div style="background-image: url('http://devs.zsicp.com/public/upload/person/normal/userlogo.png');background-size: 100% 100%;background-repeat: no-repeat;"></div>
                        {/if}
                      </div>
                    </div>
                </div>
                <div class="margin-10">
                    <div class="font-s14">欢迎,{$userinfo['db1']['username']}</div>
                   <!--  <div class="font-s16">{$historydata.count_income?:0}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.count_yesterday_income?:0}</div> -->
                </div>
                <div class="">
                    <div class="font-s14">
                        
 {switch name="userinfo.db1.authorize" }
    {case value='0'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FFB800 "></i>访客</a>{/case}
    {case value='1'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#009688 "></i>超级管理员</a>{/case}
    {case value='2'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>企业管理员</a>{/case}
    {case value='3'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>部门经理</a>{/case}
    {case value='4'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>员工</a>{/case}
    {case value='5'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>保安经理</a>{/case}
    {case value='6'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>门卫</a>{/case}
    {case value='8'}<a class="margin-10" href="javascript:;"><i class="layui-icon" style="font-size: 32px;color:#FF5722 "></i>物业管理员</a>{/case}
    {default  /}访客
 {/switch}

                    </div>

                </div>

                <div class="margin-10">
                    <div class="font-s14">登录时间,{$userinfo['db1']['login_at']}</div>

                </div>

            </div>
        </div>
        {if $userinfo['db2']}
              <div class="layui-col-md12 margin-bottom-15">
            <div class="layui-row">
                <div class="text-center">
                   <!--  <i class="layui-icon color-orange" style="font-size:60px;line-height:72px">&#xe65e;</i> -->
                </div>
                <div class="margin-10">
                    <div class="font-s14">{$userinfo['db2']['company_name']|default=""}</div>
                </div>
                <div class="margin-10">
                    <div class="font-s14">{$userinfo['db2']['dept_name']|default=""}</div>
                </div>
<!--                 <div class="">
                    <div class="font-s14">
                           {$userinfo['db2']['role_name']|default=""}
                    </div>

                </div> -->
<!-- 
                <div class="">
                    <div class="font-s14">登录时间,{$userinfo['db1']['login_at']}</div>

                </div> -->

            </div>
        </div>
        {/if}
<!--         <div class="layui-col-md6 margin-bottom-15 ">
            <div class="layui-row">
                <div class="layui-col-xs3 text-center">
                    <i class="layui-icon color-blue" style="font-size:60px;line-height:72px">&#xe663;</i>
                </div>
                {if $userinfo['db1']['authorize'] != 8}
                <div class="layui-col-xs4">
                    <div class="font-s14">新增用户数</div>
                    <div class="font-s16">{$historydata.nowday_user}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.yesterday_user}</div>
                </div>
                {/if}
                <div class="layui-col-xs5">
                    <div class="font-s14">产生访问用户数</div>
                    <div class="font-s16">{$historydata.count_visit_user}</div>
                    <div class="font-s12 color-desc">昨日：{$historydata.count_yesterday_visit_user?:0}</div>
                </div>
            </div>
        </div> -->
    </div>
</div>


<div class="think-box-shadow store-total-container notselect">
    <div class="margin-bottom-15">功能模块</div>
    <div class="layui-row layui-col-space15">

<div class="layui-row layui-col-space10">
  <div class="layui-col-md4 text-center">
 <div class="layui-row grid-demo">
    <a data-open="{:url('visitor/visitor/index')}?spm=m-70-219">
      <div class="layui-col-md9 layui-input-block">
         <i class="layui-icon" style="font-size: 30px">&#xe66f;</i>   
      </div>
      <div class="layui-col-md9 layui-input-block">
          访客管理
      </div>
      </a>
    </div>

 


  </div>
  <div class="layui-col-md4 text-center">
     <div class="layui-row grid-demo">
        <a  data-open="{:url('invitation/invitation/index')}?apptype=app&spm=m-70-217">
      <div class="layui-col-md9 layui-input-block">
         <i class="layui-icon" style="font-size: 30px">&#xe6b2;</i>   
      </div>
      <div class="layui-col-md9 layui-input-block">
          邀请管理
      </div>
  </a>
    </div>
  </div>
{if $userinfo['db1']['authorize'] == 1 || $userinfo['db1']['authorize'] == 8}
  <div class="layui-col-md4 text-center">
     <div class="layui-row grid-demo">
        <a  data-open="{:url('visitor/visitor/index')}?spm=m-209-210-211">
      <div class="layui-col-md9 layui-input-block">
         <i class="layui-icon" style="font-size: 30px">&#xe613;</i>   
      </div>
      <div class="layui-col-md9 layui-input-block">
          用户单位管理
      </div>
        </a>
    </div>
  </div>
{/if}
{if $userinfo['db1']['authorize'] == 2}
  <div class="layui-col-md4 text-center">
     <div class="layui-row grid-demo">
        <a  data-open="{:url('company/department/index')}?spm=m-57-58-62">
      <div class="layui-col-md9 layui-input-block">
         <i class="layui-icon" style="font-size: 30px">&#xe613;</i>   
      </div>
      <div class="layui-col-md9 layui-input-block">
          部门管理
      </div>
        </a>
    </div>
  </div>
{/if}
</div>
        <!-- {if $userinfo['db1']['authorize'] == 0 || $userinfo['db1']['authorize']== 1 || $userinfo['db1']['authorize']== 8} -->
<!--         <div class="layui-col-sm8 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-125deg,#57bdbf,#2f9de2)">
                <div>企业入驻总量</div>
                <div>{$historydata.count_company}</div>
                <div>当前入驻企业</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-template-1"></i>
        </div>
        {/if}
        {if $userinfo['db1']['authorize'] != 8}
        <div class="layui-col-sm6 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-125deg,#ff7d7d,#fb2c95)">
                <div>用户总量</div>
                <div>{$historydata.count_user}</div>
                <div>当前用户总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-user"></i>
        </div>
        {/if}
        <div class="layui-col-sm6 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-113deg,#c543d8,#925cc3)">
                <div>产生访问数量</div>
                <div>{$historydata.count_visit}</div>
                <div>来访总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-read"></i>
        </div>
        <div class="layui-col-sm6 layui-col-md3">
            <div class="store-total-item nowrap" style="background:linear-gradient(-141deg,#ecca1b,#f39526)">
                <div>邀请总量</div>
                <div>{$historydata.count_appointment}</div>
                <div>发出邀请函总数量</div>
            </div>
            <i class="store-total-icon layui-icon layui-icon-survey"></i>
        </div> -->
    </div>
</div>

<div class="think-box-shadow store-total-container">
    <div class="margin-bottom-15"></div>
   
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label"></label>

                 <button type="button" id="aweekbtn" class="layui-btn layui-btn-sm">近一周访问量</button>
                 <button type="button" id="amonthbtn" class="layui-btn layui-btn-sm">近一个月访问量</button>

        </div>
            <div class="layui-form-item layui-inline">
            <label class="layui-form-label">时间范围</label>
            <div class="layui-input-inline">
                <input data-date-range name="create_at" id="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择添加时间" class="layui-input">
            </div>
        </div>
    <div id="main" style="height:390px"></div>
</div>

{if $userinfo['db1']['authorize']==199999}
<div class="think-box-shadow store-total-container">
    <div class="margin-bottom-15">访客信息</div>
    <div class="layui-row layui-col-space15">

       {if $userinfo['db1']['authorize']==0 || $userinfo['db1']['authorize']==1}
        <div class="layui-col-md6 margin-bottom-15">
            <div class="layui-row">
                <div class="layui-col-xs6 text-center">
                    <img data-tips-image src="http://pc.zsicp.com/static/theme/img/headimg.png">
                </div>
                <div class="layui-col-xs4">
                    <div class="font-s16 margin-bottom-10">实时访客信息</div>
                    <div class="font-s14 margin-bottom-10">姓名:</div>
                    <div class="font-s14 margin-bottom-10">身份证:</div>
<!--                     <div class="font-s14 margin-bottom-10">地址:</div> -->
                    <div class="font-s13 color-desc"></div>
                </div>
                <div class="layui-col-xs5">
                    <div class="font-s16">来访信息</div>
                    <div class="font-s14 margin-bottom-10">来访时间:</div>
                    <div class="font-s14 color-desc margin-bottom-10"></div>
                </div>
            </div>
        </div>
        {/if}
        <div class="layui-col-md6 margin-bottom-15">
            <div class="layui-row">
                <div class="layui-col-xs3 text-center">
                    <i class="layui-icon color-green" style="font-size:60px;line-height:72px">&#xe63c;</i>
                </div>
                {if $userinfo['db1']['authorize'] != 8}
                <div class="layui-col-xs4">
                    <div class="font-s16">功能选项</div>
       
                    <div class="font-s14 margin-bottom-10">
                        <button data-modal='{:url("setting_vister")}' data-title="设置访客到访公司" type="button" class="layui-btn  layui-btn-normal">
                        <i class="layui-icon">&#xe66f;</i> 访客到访设置
                    </button></div>
                    <div  class="font-s14 margin-bottom-10 color-desc">
                                          <button data-modal='{:url("senwx_message")}' data-title="发送消息"  type="button" class="layui-btn  layui-btn-normal">
                        <i class="layui-icon">&#xe63a;</i> 发送微信消息
                    </button></div>

                    </div>
                </div>
                {/if}
                <div class="layui-col-xs5 text-right">
                    <div class="font-s14">-</div>
                    <div class="font-s16">-</div>
                    <div class="font-s12 color-desc">--</div>
                </div>
            </div>
        </div>
    </div>
</div>
{/if}



<!--  <table class="layui-table" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>


            <th class='list-table-sort-td'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-left nowrap'>-</th>
            <th class='text-left nowrap'>访客姓名</th>
            <th class='text-left nowrap'>到访公司</th>
			<th class='text-left nowrap'>拜访部门</th>
			<th class='text-left nowrap'>接见员工</th>
            <th class='text-center nowrap'>到访状态</th>
            <th class='text-left nowrap'>拜访时间</th>
            <th class='text-left nowrap'></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>

        {foreach $list as $key=>$vo}
        <tr data-dbclick data-modal='{:url("visitor/record/details")}?id={$vo.id}'>
              <td class='text-left nowrap'></td>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class='list-table-sort-td'>
                <label>{$vo.id}</label>
            </td>
            <td class='text-left nowrap'>{$vo.vister_name|default=''}</td>
            <td class='text-left nowrap'>{$vo.vister_company_name|default='-'}</td>
			<td class='text-left nowrap'>{$vo.address|default='-'}</td>
			<td class='text-left nowrap'>{$vo.app_user_name|default=''}</td>
            <td class='text-center nowrap'>
                {eq name='vo.appointment_status' value='0'}<span class="color-red">未到访</span>{/eq}
                {eq name='vo.appointment_status' value='1'}<span class="color-green">已到访</span>{/eq}
            </td>
            <td class='text-left nowrap'>
                {$vo.app_visittime|format_datetime}
            </td>

        </tr>
        {/foreach}
        </tbody>
    </table>


    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
 -->





<!-- <div class="layui-row layui-col-space15">
    <div class="layui-col-md6">
        <div class="think-box-shadow">
            <table class="layui-table" lay-skin="line" lay-even>
                <caption class="text-left margin-bottom-15 font-s14">系统信息</caption>
                <colgroup>
                    <col width="30%">
                </colgroup>
                <tbody>
                <tr>
                    <td>当前程序版本</td>
                    <td>{:sysconf('app_version')}</td>
                </tr>
                <tr>
                    <td>运行PHP版本</td>
                    <td>{$Think.PHP_VERSION}</td>
                </tr>
                <tr>
                    <td>ThinkPHP版本</td>
                    <td>{$think_ver}</td>
                </tr>
                <tr>
                    <td>MySQL数据库版本</td>
                    <td>{$mysql_ver}</td>
                </tr>
                <tr>
                    <td>服务器操作系统</td>
                    <td>{:php_uname('s')}</td>
                </tr>
                <tr>
                    <td>WEB运行环境</td>
                    <td>{:php_sapi_name()}</td>
                </tr>
                <tr>
                    <td>上传大小限制</td>
                    <td>{:ini_get('upload_max_filesize')}</td>
                </tr>
                <tr>
                    <td>POST大小限制</td>
                    <td>{:ini_get('post_max_size')}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="layui-col-md6">
        <div class="think-box-shadow">
            <table class="layui-table" lay-skin="line" lay-even>
                <caption class="text-left margin-bottom-15 font-s14">产品团队</caption>
                <colgroup>
                    <col width="30%">
                </colgroup>
                <tbody>
                <tr>
                    <td>产品名称</td>
                    <td>协成智能访客系统</td>
                </tr>
                <tr>
                    <td>在线体验</td>
                    <td><a target="_blank" href="http://demo.thinkadmin.top">http://demo.thinkadmin.top</a></td>
                </tr>
                <tr>
                    <td>官方QQ群</td>
                    <td>
                        <a href="http://shang.qq.com/wpa/qunwpa?idkey=ae25cf789dafbef62e50a980ffc31242f150bc61a61164458216dd98c411832a">
                            <img src="//pub.idqqimg.com/wpa/images/group.png" style="height:18px;width:auto" target="_blank">
                        </a>
                    </td>
                </tr>
                <tr>
                    <td>项目地址</td>
                    <td><a target="_blank" href="https://github.com/zoujingli/ThinkAdmin">https://github.com/zoujingli/ThinkAdmin</a></td>
                </tr>
                <tr>
                    <td>BUG反馈</td>
                    <td><a target="_blank" href="https://github.com/zoujingli/ThinkAdmin/issues">https://github.com/zoujingli/ThinkAdmin/issues</a></td>
                </tr>
                <tr>
                    <td>开发团队</td>
                    <td><a href="http://www.cuci.cc" target="_blank">协成科技有限公司</a></td>
                </tr>
                <tr>
                    <td>团队官网</td>
                    <td><a target="_blank" href="http://www.cuci.cc">http://www.cuci.cc</a></td>
                </tr>
                <tr>
                    <td>办公地址</td>
                    <td>广东省中山市石岐区东区软件园308</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div> -->

<!-- 轮播头像 -->
<script type="text/javascript">
    layui.use('carousel', function(){
  var carousel = layui.carousel;
  //建造实例
  carousel.render({
    elem: '#uhead-img'
    ,width: '130px' //设置容器宽度
    ,height:'130px'
    ,arrow: 'always' //始终显示箭头
    ,indicator:'inside'
    ,arrow:'none'
    //,anim: 'updown' //切换动画方式
  });
});
</script>


<!-- webcosket 推送 -->
<script type="text/javascript">
    ws = new WebSocket("wss://pc.zsicp.com/m_wss");
    
    // ws.onopen = function(){
    //     var sdata = {
    //         'type':'bind',
    //         'authorize':eval('{$userinfo["db1"]["authorize"]}'),
    //     }
    //     ws.send(JSON.stringify(sdata));
    // }
    // 服务端主动推送消息时会触发这里的onmessage
    ws.onmessage = function(e){
        // json数据转换成js对象
        var data = JSON.parse(e.data);
        // console.log(data);
        var type = data.data.type || '';
        switch(type){
            case 'init':
                // 利用jquery发起ajax请求，将client_id发给后端进行uid绑定
                $.post(
                    "{:url('index/bind')}",
                    {client_id: data.data.client_id},
                    function(redata)
                    {
                        if(redata.code==1){
                            var sdata = {
                                'type':'bind',
                                'client_id':data.data.client_id
                            }
                            ws.send(JSON.stringify(sdata));
                        }
                        //console.log(data);
                    },
                    'json'
                );
                break;
            case  'indexdata':
                let indexInfo = data.data.historydata
                $('#timeer').text(data.data.time)
                if(indexInfo){
                    if(indexInfo.count_company!=null){
                        $('#count-company').text(indexInfo.count_company)
                    }
                    $('#count-user').text(indexInfo.count_user)
                    $('#count-visit').text(indexInfo.count_visit)
                    $('#count-appointment').text(indexInfo.count_appointment)
                }
                
                if(data.data.re_data == 'false'){
                    setInterval(function(){
                        senindex()
                    },1500)
                }

                break;
            // 默认心跳
            default :
                
        }
    };
    function senindex(){
        var sdata = {
            'type':'indexdata',
            'authorize':eval('{$userinfo["db1"]["authorize"]}'),
        }
        ws.send(JSON.stringify(sdata));
    }
</script>
<!-- eacharts -->
<script type="text/javascript">
    var url = '{:url("admin/index/main")}'
    var data = []
    var date = []
    var date_app_count = []
    $(document).ready(function(){

        $.post(url, {'echarts':'week'}, function(result) {
            if (result.code == 200) {
                   result.data.forEach(function(item,index){
                    date.push(item.datelist)
                    date_app_count.push(item.app_count)
                })
                data['date'] = date
                data['date_app_count'] = date_app_count
                showecharts(data)
                //成功
                // return dialog.success(result.message, jump_url);
            } else if (result.code == 400) {
                // 失败
                // return dialog.error(result.message);
            }
        }, "JSON");
       
    });
    $('input[name="create_at"]').change(function(){
        console.log( $('input[name="create_at"]').val())
        var echarts_search_time = $('input[name="create_at"]').val()
        if(echarts_search_time){
            data = []
            date = []
            date_app_count = []
            $.post(url, {'echarts':'date','echarts_time':echarts_search_time}, function(result) {
                console.log(result)
    
                if (result.code == 200) {
    
                    result.data.forEach(function(item,index){
                        date.push(item.datelist)
                        date_app_count.push(item.app_count)
                    })
                    data['date'] = date
                    data['date_app_count'] = date_app_count
                    showecharts(data)
                    //成功
                    // return dialog.success(result.message, jump_url);
                } else if (result.code == 400) {
                    // 失败
                    // return dialog.error(result.message);
                }
            }, "JSON");
        }

    })
    $('#aweekbtn').on('click',function(){
        data = []
        date = []
        date_app_count = []
        $.post(url, {'echarts':'week'}, function(result) {
            console.log(result)

            if (result.code == 200) {

                result.data.forEach(function(item,index){
                    date.push(item.datelist)
                    date_app_count.push(item.app_count)
                })
                data['date'] = date
                data['date_app_count'] = date_app_count
                showecharts(data)
                //成功
                // return dialog.success(result.message, jump_url);
            } else if (result.code == 400) {
                // 失败
                // return dialog.error(result.message);
            }
        }, "JSON");

         
    })
    $('#amonthbtn').on('click',function(){
        data = []
        date = []
        date_app_count = []
        var data = {'giao':'Yes'}
        $.post(url, {'echarts':'month'}, function(result) {
            if (result.code == 200) {
                   result.data.forEach(function(item,index){
                    date.push(item.datelist)
                    date_app_count.push(item.app_count)
                })
                data['date'] = date
                data['date_app_count'] = date_app_count
                showecharts(data)
                //成功
                // return dialog.success(result.message, jump_url);
            } else if (result.code == 400) {
                // 失败
                // return dialog.error(result.message);
            }
        }, "JSON");
    })

    function showecharts_bck(edata){
        require(['echarts'], function (echarts, chart) {
        chart = echarts.init(document.getElementById('main'));
        chart.clear();
        window.onresize = chart.resize;

        if(edata){
            chart.setOption({
                // title: {
                //      text: '堆叠区域图'
                //  },
                 tooltip: {
                     trigger: 'axis',
                     axisPointer: {
                         type: 'cross',
                         label: {
                             backgroundColor: '#1b90ee'
                         }
                     }
                 },
                 color:['#1b90ee','#01da8c'],
                 legend: {

                     data: ['来访数量', '产生访客数量']
                 },
                 toolbox: {
                     feature: {
                         saveAsImage: {}
                     }
                 },
                 grid: {
                     left: '3%',
                     right: '4%',
                     bottom: '3%',
                     containLabel: true
                 },
                 xAxis: [
                     {
                         type: 'category',
                         boundaryGap: false,
                         data: edata.date,
                         axisLabel:{
                                 interval: 0,
                                 formatter:function(value,index){  
                if (index % 2 != 0) {  
                    return '\n\n' + value;  
                }  
                else {  
                    return value;  
                } 
            }

                        }

                     }
                 ],

                 // yAxis: [
                 //     {
                 //         type: 'value'
                 //     }
                 // ],
                 yAxis: [{
                 type: 'value',
                 scale: true,
                 max: function (value) {
                    console.log(value)
                    return Math.ceil(value.max / 50) * 20 + 1;
                     // return Math.ceil(value.max / 50) * 50 + 100;
                 },
                 axisLabel: {
                     color: '#2f9de2',
                     formatter: "{value}人"
                 },
                 splitLine: {
                     lineStyle: {
                         type: 'dashed',
                         color: '#cccccc'
                     }
                      }
                 }],
                     dataZoom: [
        {
            type: 'slider',//滑动轴
            start: 20,//距离左侧0刻度的距离，1%
            end: 80//距离左侧0刻度的距离，35%，相当于规定了滑动的范围
        }
    ],
                 series: [
                     {
                         type: 'line',
                         name: '产生访客数量',
                         stack: '总量',
                         areaStyle: {
                            color:'#1b90ee'
                         },
                         // label: {normal: {show: true, position: ['30%', '-100%'], offset: [10, -10], formatter: "访客{c}量"}},
                         data: edata.date_app_count
                     },
                     {
                         type: 'line',
                         name: '来访数量',
                         stack: '总量',
                         areaStyle: {
                            color:'#b1ffe3'
                         },
                         // label: {normal: {show: true, position: ['30%', '-100%'], offset: [10, -10], formatter: "来访数{c}"}},
                         data: edata.date_app_count
                     },
                 ]
                         });
        }
    });
    }


    function showecharts(edata){
        //数据处理
        var sourcelist = [
            ['product','产生访客数量','来访数量'],
        ];
        edata.date.forEach(function(item_date,index_date){
            // edata.date_app_count.forEach(function(item_count,index_count){
            sourcelist.push([item_date,edata.date_app_count[index_date],edata.date_app_count[index_date]*2])
        // })
        })
        console.log(sourcelist)
        
        require(['echarts'], function (echarts, chart) {
        chart = echarts.init(document.getElementById('main'));
        chart.clear();
        window.onresize = chart.resize;

        if(edata){
            var chartoptions = {
                legend: {},
                color:['#4cabce','#006699'],
                tooltip: {},
                dataset: {
                    source: sourcelist
                },
                xAxis: {type: 'category'},
                yAxis: {},
                // Declare several bar series, each will be mapped
                // to a column of dataset.source by default.
                series: [
                    {type: 'bar'},
                    {type: 'bar'},
                ]
            }
            chart.setOption(chartoptions);

        }

    });
    }

</script>
{/block}
